#ifndef INTELLIGENTRESIZEUTILITY_H
#define INTELLIGENTRESIZEUTILITY_H
#include <QColor>
#include <qimage.h>
#include <math.h>
#include <QQueue>
#include <limits.h>
#include <QLinkedList>
#include <iostream>
#include <qpoint.h>
using namespace std ;
enum NODE_TYPE{INITIALIZED,ACTIVE,EXPANDED};
enum POSITION {RIGHT, UPPER_RIGHT, UPPER, UPPER_LEFT,LEFT,LOWER_LEFT,LOWER,LOWER_RIGHT};

class Pixel{
private :
        unsigned int x,y;
        QColor color;
        int red,green,blue;
        bool seed;
        Pixel *next;
        NODE_TYPE pixelState;        
        double maxD;
        bool contour;
public :
        Pixel(QRgb,int x, int y);
        Pixel();
        bool operator== ( const Pixel & other )const ;
        double getMaxD();
        void getNeighbors();
        bool isSeed();
        //QColor getColor();
        QRgb   getRgb();
        void setColor(QRgb );
        void  setNext(Pixel *next);
        Pixel *getNext();
        NODE_TYPE getPixelState();
        void updateRGB();
        void setSeed(bool );
        unsigned int getX();
        unsigned int getY();
        void setX(unsigned int x );
        void setY(unsigned int y);
        void calculateD();
        void calculateCost();
        void setPixelState(NODE_TYPE state);
        struct Neighbor* neighbor;
        //double calculateCost(Pixel*);
        void setContour(bool isContour);
        bool isContour();
};
  struct Neighbor
  {
      Pixel *pixel;
      POSITION   Position;
      double costR;
      double costG;
      double costB;
      double cost;
      double D;
  };
class IntelligentResizeUtility
{
public:

    IntelligentResizeUtility(QImage *);
//    IntelligentResizeUtility();
    ~IntelligentResizeUtility();
    static Pixel *pixelsGrid;
    static int width;
    static int height;
    static double maxD;
    void dijkstra(Pixel * seed);
    void dijkstra(Pixel * seed,Pixel* finalSeed);
    void tracePath(Pixel* pixelStart,Pixel* pixelEnd,QLinkedList<QPoint>* path);
    void cutContour(QImage *);
    Pixel*  retrivePixel( unsigned int x,unsigned int y);
private :
    QLinkedList<Pixel> pathList;
    bool isGray;
    QLinkedList<Pixel *> PixelQueue;
    double *distance;
    

    
    
    
};

#endif // INTELLIGENTRESIZEUTILITY_H
